﻿using System;
using UnityEngine;

// Token: 0x0200039A RID: 922
public class ColorPalette : MonoBehaviour
{
	// Token: 0x060016D3 RID: 5843 RVA: 0x0009967C File Offset: 0x0009787C
	private void Start()
	{
		for (int i = 0; i < ColorPaletteData.colors.Length; i++)
		{
			ColorPaletteCell colorPaletteCell = UnityEngine.Object.Instantiate<ColorPaletteCell>(this.cellOriginal);
			colorPaletteCell.gameObject.SetActive(true);
			colorPaletteCell.Setup(i, ColorPaletteData.colors[i], new Action<int>(this.OnSave), new Action<int>(this.OnLoad));
			colorPaletteCell.transform.SetParent(this.paletteArea, false);
			this.cells[i] = colorPaletteCell;
		}
	}

	// Token: 0x060016D4 RID: 5844 RVA: 0x00099704 File Offset: 0x00097904
	private void OnEnable()
	{
		for (int i = 0; i < ColorPaletteData.colors.Length; i++)
		{
			if (this.cells[i] != null)
			{
				this.cells[i].SetColor(ColorPaletteData.colors[i]);
			}
		}
	}

	// Token: 0x060016D5 RID: 5845 RVA: 0x0009975C File Offset: 0x0009795C
	private void Update()
	{
	}

	// Token: 0x060016D6 RID: 5846 RVA: 0x00099760 File Offset: 0x00097960
	private void OnSave(int id)
	{
		ColorPaletteData.colors[id] = this.picker.EditColor;
		this.cells[id].SetColor(ColorPaletteData.colors[id]);
	}

	// Token: 0x060016D7 RID: 5847 RVA: 0x0009979C File Offset: 0x0009799C
	private void OnLoad(int id)
	{
		this.picker.EditColor = ColorPaletteData.colors[id];
	}

	// Token: 0x04001A95 RID: 6805
	private const int CELL_NUM = 50;

	// Token: 0x04001A96 RID: 6806
	[SerializeField]
	private ColorPicker picker;

	// Token: 0x04001A97 RID: 6807
	[SerializeField]
	private ColorPaletteCell cellOriginal;

	// Token: 0x04001A98 RID: 6808
	[SerializeField]
	private RectTransform paletteArea;

	// Token: 0x04001A99 RID: 6809
	private ColorPaletteCell[] cells = new ColorPaletteCell[50];
}
